feat(clerk-react,clerk-js, types,shared): Introduce Clerk.status#5476
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…clerk-has-failed-to-load-from # Conflicts: # packages/react/src/isomorphicClerk.ts
🦋 Changeset detectedLatest commit: b04005d The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The inline script might fail before the event listeners are attached which causes an infinite pending state. Instead, we would like to retry fetching the script and/or throw an error.
This reverts commit 129d423.
…clerk-has-failed-to-load-from # Conflicts: # packages/clerk-js/src/core/auth/AuthCookieService.ts
…clerk-has-failed-to-load-from
…clerk-has-failed-to-load-from # Conflicts: # packages/clerk-js/bundlewatch.config.json
…clerk-has-failed-to-load-from
|
!snapshot |
…clerk-has-failed-to-load-from
…clerk-has-failed-to-load-from
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new status tracking property for Clerk, allowing developers to distinguish between different operational states ("loading", "error", "ready", and "degraded"). It updates the core Clerk implementation, React hooks, context providers, and UI components to leverage the new Clerk.status and adjust the computed loaded flag accordingly.
- Adds a new Clerk.status property with corresponding event handling.
- Refactors many loading checks across the SDK to use Clerk.status.
- Introduces new React components ( and ) and updates tests/documentation to support the new status logic.
Reviewed Changes
Copilot reviewed 20 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/isomorphicClerk.ts | Introduces Clerk.status, replaces internal loaded checks |
| packages/react/src/hooks/utils.ts | Updates event listener to use Clerk.status |
| packages/react/src/contexts/ClerkContextProvider.tsx | Refactors context to derive state from Clerk.status |
| packages/react/src/components/* | Adjusts control components to render based on the new status |
| packages/nextjs/* | Updates Next.js integrations similarly |
| packages/clerk-js/src/core/* | Revises the core Clerk logic and error handling to emit proper status |
| integration/tests/* | Adds tests to verify correct status transitions |
| .changeset/* | Updates changesets to document the new status feature |
Files not reviewed (4)
- .typedoc/tests/snapshots/file-structure.test.ts.snap: Language not supported
- packages/chrome-extension/src/tests/snapshots/exports.test.ts.snap: Language not supported
- packages/clerk-js/bundlewatch.config.json: Language not supported
- packages/react-router/src/tests/snapshots/exports.test.ts.snap: Language not supported
…clerk-has-failed-to-load-from # Conflicts: # integration/testUtils/index.ts
Description
Introduce
useClerk().status,Clerk.statusalongside<ClerkFailed/>and<ClerkDegraded/>.useClerk().statusPossible values are:
loading(initial state)errorset when hotloading clerk-js failed orClerk.load()failedreadyset when Clerk is fully operationaldegradedset when Clerk is partially operationaluseClerk().loadedistruewhenuseClerk().statusis either"ready"or"degraded".useClerk().loadedisfalsewhenuseClerk().statusis"loading"or"error".Important
🚨🚨
Clerk.statusbecomesloadingupon instantiation not upon calling.load()New APIs
on()
Calls handler on every status event with the new status as parameter
Calls handler immediately with the last payload of the event.
off()
Accepts a handler to unregister from the specified event.
Removes all handlers for the specified event.
New Components
<ClerkFailed/><ClerkDegraded/>Clerk.status values
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change